package com.ghy.utils;

public class Message<T>  {
    //状态码
    private Integer status;

    private String code;
    //状态
    private String message;

    private T data;
    public static <T> Message<T> ok(){
        return new Message<T>();
    }
    public static <T> Message<T> ok(T data){
        return new Message<T>(data);
    }

    public static <T> Message<T> ok(T data, Integer status){
        return new Message<T>(data,status);
    }




    public Message(Throwable e) {
        this.message = e.getMessage();
        this.message="NO";
    }
    public Message() {
        this.status = 200;
        this.code = "ok";
        this.message = "成功";
    }

    public Message(T data) {

        this.status = 200;
        this.code = "ok";
        this.message = "成功";
        this.data = data;
    }

    public Message(T data, Integer status){
        this.status=status;
        this.data=data;
        this.code = "no";
        this.message = "失败";
    }

    public Message(Integer status, String code, String message, T data) {
        super();
        this.status = status;
        this.code = code;
        this.message = message;
        this.data = data;
    }


    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }


}
